*******************************************************************************
*** Description: 	This document provides code for reproducing the tables	***
***					and figures in Supplementary Material for the paper, 	***
***					"The Pigmentocracy of Executive Approval," which is 	***
***					authored by Shane P. Singh and Ryan	E. Carlin and 		***
***					appears in Comparative Political Studies.				***
***					It also provides the code for reproducing statistics 	***
***					associated with claims made in the text.				***
*******************************************************************************




**************
**************
*Set the Version                                                                                                                                 
**************
**************
version 17



**************
**************
*Install Required Package                                                                                                                  
**************
**************
ssc install coefplot 



**************
**************
*Open the AmericasBarometer Dataset
**************
**************
use "AmericasBarometer_Singh_and_Carlin_CPS.dta", clear



**************
**************
*Figure A3
**************
**************
xtreg approve_prez c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro, i(cntryyearnum)  re

sum skin_distance_leader
global min = r(min)
global max = r(max)
global increment_light = abs(($min-0)/20)
global increment_dark = abs(($max-0)/20)
margins, at(skin_distance_leader = ($min($increment_light)0) darker_than_leader=0) at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1) predict(xb) atmeans level(90) post

marginsplot, level(90)  ///
     recast(line) recastci(rarea) scheme(s1color) ///
     ci1opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot1opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 ci2opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot2opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 title("")  ///
	 xsize(4.25)	 ///
	 addplot(histogram skin_distance_leader   /// 
		, 	yaxis(2) xaxis(2) lcolor(black) lpattern(solid) ///
							xlabel(	-9 "-9"  ///
						-6 `""-6" "{&larr}  Lighter" "   than Leader""'  ///
						-3 	"-3"  ///
						0 `""0" "Same Skin Tone"   "as Leader""' ///
						3 	"3"   ///
						6 `""6" "Darker  {&rarr}" "than Leader     ""' ///
						9 "9" ///
					, labsize(small)) ylabel(, labsize(small)) ///
					xscale(range(-9 9) lwidth(none)  axis(2)) xlabel(none, axis(2)) ///
			xtitle("") ///
			xtitle("", axis(2)) ///
			ylabel(2.75(.25)3.75, labsize(small))  yscale(range(2.60 3.80)) ///
			ylabel(0 10, axis(2)) fcolor(gs2) lcolor(gs2) lwidth(vthin) lalign(center) gap(0) width(.15)  /// 
			yscale(off   axis(2)) ///
			ytitle("Predicted Approval of Leader", size(medsmall)) ///
			ytitle("", axis(2)) ///
			legend(off))



**************
**************
*Figure A4
**************
**************	
*This first set of steps facilitates for predictions up to the 0 line for each country-year. 
gen skin_distance_leader_counter = skin_distance_leader 
tabulate race, gen(racedummy)
egen seq = fill(1 2 1 2)

foreach x of varlist racedummy* {
	sum skin_distance_leader  if `x' == 1  & darker_than_leader == 0 
	replace skin_distance_leader_counter = 0 if skin_distance_leader == r(max) & `x' == 1  & darker_than_leader == 0 & seq == 1
	sum skin_distance_leader  if `x' == 1  & darker_than_leader == 1 
	replace skin_distance_leader_counter = 0 if skin_distance_leader == r(min) & `x' == 1  & darker_than_leader == 1 & seq == 1
	}

	

mixed approve_prez c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader education unemployed female i.ego_retro i.socio_retro ||   race: skin_distance_leader darker_than_leader#c.skin_distance_leader,   || cntryyearnum: ,  mle   
predict reffect_*, reffects //*first get the random effects
gen yhat_reffects_lighter = (_b[_cons] + reffect_3) + (_b[skin_distance_leader]+ reffect_1) *skin_distance_leader_counter  if  darker_than_leader == 0 
gen yhat_reffects_darker = (_b[_cons] + reffect_3) + (_b[skin_distance_leader]+ reffect_1 +  _b[1.darker_than_leader#c.skin_distance_leader] + reffect_2) *skin_distance_leader_counter  if   darker_than_leader == 1 
gen yhat_lighter = (_b[_cons]) + (_b[skin_distance_leader]) *skin_distance_leader_counter  if  darker_than_leader == 0 
gen yhat_darker = (_b[_cons]) + (_b[skin_distance_leader] + _b[1.darker_than_leader#c.skin_distance_leader]) *skin_distance_leader_counter  if   darker_than_leader == 1 



sort  race skin_distance_leader_counter 
twoway ///
		line yhat_reffects_lighter   skin_distance_leader_counter if racedummy1 == 1, connect(ascending) lcolor(red%50) lwidth(medium) ///
	|| 	line yhat_reffects_darker   skin_distance_leader_counter  if racedummy1 == 1, connect(ascending)  lcolor(red%50) lwidth(medium)  ///
	||	line yhat_reffects_lighter   skin_distance_leader_counter if racedummy2 == 1, connect(ascending) lcolor(blue%50) lwidth(medium) ///
	|| 	line yhat_reffects_darker   skin_distance_leader_counter  if racedummy2 == 1, connect(ascending)  lcolor(blue%50) lwidth(medium)  ///
	||	line yhat_reffects_lighter   skin_distance_leader_counter if racedummy3 == 1, connect(ascending) lcolor(green%50) lwidth(medium) ///
	|| 	line yhat_reffects_darker   skin_distance_leader_counter  if racedummy3 == 1, connect(ascending)  lcolor(green%50) lwidth(medium)  ///
	||	line yhat_reffects_lighter   skin_distance_leader_counter if racedummy4 == 1, connect(ascending) lcolor(pink%50) lwidth(medium) ///
	|| 	line yhat_reffects_darker   skin_distance_leader_counter  if racedummy4 == 1, connect(ascending)  lcolor(pink%50) lwidth(medium)  ///
	||	line yhat_reffects_lighter   skin_distance_leader_counter if racedummy5 == 1, connect(ascending) lcolor(orange%50) lwidth(medium) ///
	|| 	line yhat_reffects_darker   skin_distance_leader_counter  if racedummy5 == 1, connect(ascending)  lcolor(orange%50) lwidth(medium)  ///
	||	line yhat_lighter   skin_distance_leader_counter, connect(ascending) lcolor(black) lwidth(medthick) ///
	|| 	line yhat_darker   skin_distance_leader_counter, connect(ascending) lcolor(black) lwidth(medthick) ///
		, 	xlabel(	-9 "-9"  ///
						-6 `""-6" "{&larr}  Lighter" "   than Leader""'  ///
						-3 	"-3"  ///
						0 `""0" "Same Skin Tone"   "as Leader""' ///
						3 	"3"   ///
						6 `""6" "Darker  {&rarr}" "than Leader     ""' ///
						9 "9" ///
					, labsize(small)) ylabel(, labsize(small)) ///
			xscale(range(-9 9) lwidth(none)) xtitle("")  ///
			ytitle("Predicted Approval of Leader", size(medsmall)) ///
			ylabel(2.75(.25)3.75, labsize(small))  yscale(range(2.60 3.80)) ///
			xsize(4.25) scheme(s1color)  ///
			legend(order( 	///
			2 "White" 		///
			4 "Mestizo" 		///
			6 "Indigenous" 		///
			8 "Black" 		///
			10 "Mulatto"  			///
			12 "Overall"  			///
			) rows(2) size(vsmall)) 



**************
**************
*Figure A5
**************
**************	
ologit approve_prez c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro i.cntryyearnum 

sum skin_distance_leader
global min = r(min)
global max = r(max)
global increment_light = abs(($min-0)/20)
global increment_dark = abs(($max-0)/20)
margins, at(skin_distance_leader = ($min($increment_light)0) darker_than_leader=0) at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1) predict(xb) atmeans level(90) post

marginsplot, level(90)  ///
     recast(line) recastci(rarea) scheme(s1color) ///
     ci1opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot1opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 ci2opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot2opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 title("")  ///
	 xsize(4.25)	 ///
	 addplot(histogram skin_distance_leader   ///  
		, 	yaxis(2) xaxis(2) lcolor(black) lpattern(solid) ///
							xlabel(	-9 "-9"  ///
						-6 `""-6" "{&larr}  Lighter" "   than Leader""'  ///
						-3 	"-3"  ///
						0 `""0" "Same Skin Tone"   "as Leader""' ///
						3 	"3"   ///
						6 `""6" "Darker  {&rarr}" "than Leader     ""' ///
						9 "9" ///
					, labsize(small)) ylabel(, labsize(small)) ///
					xscale(range(-9 9) lwidth(none)  axis(2)) xlabel(none, axis(2)) ///
			xtitle("") ///
			xtitle("", axis(2)) ///
			ylabel(.75(.25)1.75, labsize(small))  yscale(range(0.6 1.8)) ///
			ylabel(0 10, axis(2)) fcolor(gs2) lcolor(gs2) lwidth(vthin) lalign(center) gap(0) width(.15)  ///  
			yscale(off   axis(2)) ///
			ytitle("Predicted Latent Approval of Leader", size(medsmall)) ///
			ytitle("", axis(2)) ///
			legend(off))



**************
**************
*Figure A6
**************
**************	
xtreg approve_prez c.skin_distance_leader_mode c.skin_distance_leader_mode#i.darker_than_leader_mode ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro, i(cntryyearnum)  fe

sum skin_distance_leader_mode 
global min = r(min)
global max = r(max)
global increment_light = abs(($min-0)/20)
global increment_dark = abs(($max-0)/20)
margins, at(skin_distance_leader_mode = ($min($increment_light)0) darker_than_leader_mode=0) at(skin_distance_leader_mode = (0($increment_dark)$max) darker_than_leader_mode=1) predict(xb) atmeans level(90) post

marginsplot, level(90)  ///
     recast(line) recastci(rarea) scheme(s1color) ///
     ci1opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot1opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 ci2opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot2opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 title("")  ///
	 xsize(4.25)	 ///
	 addplot(histogram skin_distance_leader_mode   /// 
		, 	yaxis(2) xaxis(2) lcolor(black) lpattern(solid) ///
							xlabel(	-9 "-9"  ///
						-6 `""-6" "{&larr}  Lighter" "   than Leader""'  ///
						-3 	"-3"  ///
						0 `""0" "Same Skin Tone"   "as Leader""' ///
						3 	"3"   ///
						6 `""6" "Darker  {&rarr}" "than Leader     ""' ///
						9 "9" ///
					, labsize(small)) ylabel(, labsize(small)) ///
					xscale(range(-9 9) lwidth(none)  axis(2)) xlabel(none, axis(2)) ///
			xtitle("") ///
			xtitle("", axis(2)) ///
			ylabel(2.75(.25)3.75, labsize(small))  yscale(range(2.60 3.80)) ///
			ylabel(0 15, axis(2)) fcolor(gs2) lcolor(gs2) lwidth(vthin) lalign(center) gap(0) width(.15)  ///  
			yscale(off   axis(2)) ///
			ytitle("Predicted Approval of Leader", size(medsmall)) ///
			ytitle("", axis(2)) ///
			legend(off))




**************
**************
*Figure A7
**************
**************	
xtreg approve_prez c.skin_distance_leader#c.skin_distance_leader c.skin_distance_leader#c.skin_distance_leader#i.darker_than_leader c.ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro, i(cntryyearnum)  fe

sum skin_distance_leader 
global min = r(min)
global max = r(max)
global increment_light = abs(($min-0)/20)
global increment_dark = abs(($max-0)/20)
margins, at(skin_distance_leader = ($min($increment_light)0) darker_than_leader=0) at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1) predict(xb) atmeans level(90) post

marginsplot, level(90)  ///
     recast(line) recastci(rarea) scheme(s1color) ///
     ci1opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot1opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 ci2opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot2opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 title("")  ///
	 xsize(4.25)	 ///
	 addplot(histogram skin_distance_leader   ///  
		, 	yaxis(2) xaxis(2) lcolor(black) lpattern(solid) ///
			xlabel(	-9 "-9"  ///
						-6 `""-6" "{&larr}  Lighter" "   than Leader""'  ///
						-3 	"-3"  ///
						0 `""0" "Same Skin Tone"   "as Leader""' ///
						3 	"3"   ///
						6 `""6" "Darker  {&rarr}" "than Leader     ""' ///
						9 "9" ///
					, labsize(small)) ylabel(, labsize(small)) ///
					xscale(range(-9 9) lwidth(none)  axis(2)) xlabel(none, axis(2)) ///		
			xtitle("") ///
			xtitle("", axis(2)) ///
			ylabel(2.75(.25)3.75, labsize(small))  yscale(range(2.60 3.80)) ///
			ylabel(0 10, axis(2)) fcolor(gs2) lcolor(gs2) lwidth(thin) lalign(center) gap(0) width(.15)  ///  
			yscale(off   axis(2)) ///
			ytitle("Predicted Approval of Leader", size(medsmall)) ///
			ytitle("", axis(2)) ///
			legend(off)) 


			

**************
**************
*Figure A8
**************
**************	
gen extreme_case = 0

preserve
collapse skin_distance_leader, by(cntryyear)
sum skin_distance_leader 
global sd = r(sd)
restore

tabulate cntryyearnum, gen(countryyeardummy)

foreach x of varlist countryyeardummy* {
	sum skin_distance_leader  if `x' == 1  
	replace extreme_case = 1 if r(mean) >  2*$sd  & `x' == 1
	replace extreme_case = 1 if r(mean) < -2*$sd  & `x' == 1
	}

drop  countryyeardummy* 

tab countryandyear if extreme_case == 1 


gen Colombia_2012 = 0
replace Colombia_2012 = 1 if countryandyear == "Colombia_2012"

gen Guatemala_2010 = 0
replace Guatemala_2010 = 1 if countryandyear == "Guatemala_2010" 

gen Haiti_2012 = 0
replace Haiti_2012 = 1 if countryandyear == "Haiti_2012" 

gen Haiti_2014 = 0
replace Haiti_2014 = 1 if countryandyear == "Haiti_2014" 

gen Jamaica_2010 = 0
replace Jamaica_2010 = 1 if countryandyear == "Jamaica_2010" 

gen Jamaica_2012 = 0
replace Jamaica_2012 = 1 if countryandyear == "Jamaica_2012" 

gen Jamaica_2014 = 0
replace Jamaica_2014 = 1 if countryandyear == "Jamaica_2014" 

gen Mexico_2012 = 0
replace Mexico_2012 = 1 if countryandyear == "Mexico_2012" 

gen Panama_2010 = 0
replace Panama_2010 = 1 if countryandyear == "Panama_2010" 

gen Panama_2012 = 0
replace Panama_2012 = 1 if countryandyear == "Panama_2012" 

gen Panama_2014 = 0
replace Panama_2014 = 1 if countryandyear == "Panama_2014" 

gen Panama_2017 = 0
replace Panama_2017 = 1 if countryandyear == "Panama_2017" 

gen Peru_2017 = 0
replace Peru_2017 = 1 if countryandyear == "Peru_2017" 

gen Trinidad_Tobago_2012 = 0
replace Trinidad_Tobago_2012 = 1 if countryandyear == "Trinidad & Tobago_2012" 

gen Trinidad_Tobago_2014 = 0
replace Trinidad_Tobago_2014 = 1 if countryandyear == "Trinidad & Tobago_2014" 


sum skin_distance_leader
global min = r(min)
global max = r(max)
sum skin_distance_leader if darker_than_leader == 0
global range_lighter = -r(min) 
sum skin_distance_leader if darker_than_leader == 1
global range_darker = r(max)


global ratio = $range_lighter/$range_darker //*use this in the rounding calculation below so that coefplot does not plot the same range for respondents lighter and darker than the leader

global increment_light = abs(($range_lighter)/(round(50*$ratio)))
global increment_dark = abs(($range_darker)/50)

global stop_point = 0-$increment_light //*create this so coefplot doesn't repeat the prediction for skin_distance_leader == 0


xtreg approve_prez c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro, i(cntryyearnum)  fe 
margins, at(skin_distance_leader = ($min($increment_light)$stop_point) darker_than_leader=0) at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1) predict(xb) atmeans level(90) post
estimates store all_country_years

xtreg approve_prez c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro if extreme_case ~= 1, i(cntryyearnum)  fe
margins, at(skin_distance_leader = ($min($increment_light)$stop_point) darker_than_leader=0) at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1) predict(xb) atmeans level(90) post
estimates store no_extreme

foreach x of varlist Colombia_2012-Trinidad_Tobago_2014{
xtreg approve_prez c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro if `x' ~= 1, i(cntryyearnum)  fe
margins, at(skin_distance_leader = ($min($increment_light)$stop_point) darker_than_leader=0) at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1) predict(xb) atmeans level(90) post
estimates store no_`x'
	}

*graph
coefplot ///
	(all_country_years, lcolor(black) lwidth(medthick) recast(line) noci) /// 
	(no_extreme, lcolor(black%60) lwidth(medthick) recast(line) noci) /// 
	(no_Colombia_2012, lcolor(black%20) recast(line) noci) /// 
	(no_Guatemala_2010, lcolor(black%20) recast(line) noci) /// 
	(no_Haiti_2012, lcolor(black%20) recast(line) noci) /// 
	(no_Haiti_2014, lcolor(black%20) recast(line) noci) /// 
	(no_Jamaica_2010, lcolor(black%20) recast(line) noci) /// 
	(no_Jamaica_2012, lcolor(black%20) recast(line) noci) /// 
	(no_Jamaica_2014, lcolor(black%20) recast(line) noci) /// 
	(no_Mexico_2012, lcolor(black%20) recast(line) noci) /// 
	(no_Panama_2010, lcolor(black%20) recast(line) noci) /// 
	(no_Panama_2012, lcolor(black%20) recast(line) noci) /// 
	(no_Panama_2014, lcolor(black%20) recast(line) noci) /// 
	(no_Panama_2017, lcolor(black%20) recast(line) noci) /// 
	(no_Peru_2017, lcolor(black%20) recast(line) noci) /// 
	(no_Trinidad_Tobago_2012, lcolor(black%20) recast(line) noci) /// 
	(no_Trinidad_Tobago_2014, lcolor(black%20) recast(line) noci) ///
		,  	scheme(s1color) grid(none) vertical  ysize(6)	 	///
			xscale(range(-22 82) lwidth(none))  ///
			xlabel(	-20 "-9"  ///
						-3.3333 `""-6" "{&larr}  Lighter" "   than Leader""'  ///
						13.333333 	"-3"  ///
						30 `""0" "Same Skin Tone"   "as Leader""' ///
						46.666667 	"3"   ///
						63.333333 `""6" "Darker  {&rarr}" "than Leader     ""' ///
						80 "9" ///
					, labsize(small)) ///
			xtitle("")  ///
			ylabel(2.75(.25)3.75, labsize(small))  yscale(range(2.60 3.80)) ///
			ytitle("Predicted Approval of Leader", size(medsmall)) ///
			legend(order(1 "Full Dataset" 2 "w/o Extreme Cases" 3 "w/o Extreme Cases, One by One") rows(3) size(vsmall)) ///
			addplot	(pci	2.75 0.75  3.5 0.75   /// **smooth out line ends
							2.75 80.15  3.5 80.15   ///
							, lwidth(thick) lcolor(white))


**************
**************
*Figure A9
**************
**************	
xtreg approve_prez c.skin_distance_leader i.ego_retro c.skin_distance_leader#c.darker_than_leader c.skin_distance_leader#c.media_exposure  c.skin_distance_leader#c.darker_than_leader#c.media_exposure  c.media_exposure  i.socio_retro ideo_distance_leader i.race education unemployed female, i(cntryyearnum)  fe

sum skin_distance_leader
global min = r(min)
global max = r(max)
global increment_light = abs(($min-0)/20)
global increment_dark = abs(($max-0)/20)
sum media_exposure, detail
global low = r(p25)
global high = r(p75)

margins, ///
	at(skin_distance_leader = ($min($increment_light)0) darker_than_leader=0 media_exposure=$low) ///
	at(skin_distance_leader = ($min($increment_light)0) darker_than_leader=0 media_exposure=$high) ///
	at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1 media_exposure=$low) ///
	at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1 media_exposure=$high) ///
	predict(xb) atmeans level(90) post
	
marginsplot, level(90)  ///
     recast(line) recastci(rarea) scheme(s1color) ///
     ci1opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot1opts(lcolor(black*1.25%50) lwidth(medium))  ///       
	 ci2opts(color(blue*.5%50) lwidth(vthin) lcolor(blue*.2%50))  /// 
     plot2opts(lcolor(blue*1.25%50) lwidth(medium))  ///  
	 ci3opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot3opts(lcolor(black*1.25%50) lwidth(medium))  ///  
	 ci4opts(color(blue*.5%50) lwidth(vthin) lcolor(blue*.2%50))  /// 
     plot4opts(lcolor(blue*1.25%50) lwidth(medium))  ///  
	 title("")  ///
	 xsize(3.75)	 ///
	 addplot(histogram skin_distance_leader  ///  
		, 	yaxis(2) xaxis(2) lcolor(black) lpattern(solid) ///
xlabel(	-9 "-9"  ///
						-6 `""-6" "{&larr}  Lighter" "   than Leader""'  ///
						-3 	"-3"  ///
						0 `""0" "Same Skin Tone"   "as Leader""' ///
						3 	"3"   ///
						6 `""6" "Darker  {&rarr}" "than Leader     ""' ///
						9 "9" ///
					, labsize(small)) ylabel(, labsize(small)) ///
					xscale(range(-9 9) lwidth(none)  axis(2)) xlabel(none, axis(2)) ///
			xtitle("") ///
			xtitle("", axis(2)) ///
			ylabel(2.75(.25)3.75, labsize(small))  yscale(range(2.60 3.80)) ///
			ylabel(0 10, axis(2)) fcolor(gs2) lcolor(gs2) lwidth(thin) lalign(center) gap(0) width(.15)  ///  
			yscale(off   axis(2)) ///
			ytitle("Predicted Approval of Leader", size(medsmall)) ///
			ytitle("", axis(2)) ///
			legend(order(8 "High Media Exposure" 7 "Low Media Exposure" ) rows(2) size(vsmall)))



			
**************
**************
*Figure A10
**************
**************
preserve

collapse GDP_growth* inflation* unemployment* leader_skin_tone skin*, by(cntryyear)
gen leader_skin_rel_citizens = -skin_distance_leader

twoway ///
		(lpolyci  leader_skin_rel_citizens GDP_growth, fcolor(black*.5%50) lcolor(black) alwidth(none) level(90) n(100) bw(4) gaussian) 	///
		(scatter  leader_skin_rel_citizens GDP_growth, msymbol(circle) mfcolor(black%60)  mlcolor(black))  ///
		,	ylabel(-4 "-4" -3  "{&larr}      "   -2 `""Lighter than" "Mean Citizen""' -1 " " 0 `""Same" "Skin Tone""'   1 " " 2 `""Darker than" "Mean Citizen""' 3  "      {&rarr}"  4 "4", labsize(vsmall)) ///
			xtitle("GDP Growth (%)", size(small))  ///
			xlabel(-5(5)15, labsize(small))  xscale(range(-6 16)) ///
			xsize(4.25) scheme(s1color) legend(off) ///
			name(leader_skin_tone_GDP_growth, replace)
			
twoway ///
		(lpolyci  leader_skin_rel_citizens GDP_growth_t_1, fcolor(black*.5%50) lcolor(black) alwidth(none) level(90) n(100) bw(4) gaussian) 	///
		(scatter  leader_skin_rel_citizens GDP_growth_t_1, msymbol(circle) mfcolor(black%60)  mlcolor(black))  ///
		,	ylabel(-4 "-4" -3  "{&larr}      "   -2 `""Lighter than" "Mean Citizen""' -1 " " 0 `""Same" "Skin Tone""'   1 " " 2 `""Darker than" "Mean Citizen""' 3  "      {&rarr}"  4 "4", labsize(vsmall)) ///
			xtitle("GDP Growth (%), Lagged", size(small))  ///
			xlabel(-5(5)15, labsize(small))  xscale(range(-6 16)) ///
			xsize(4.25) scheme(s1color) legend(off) ///
			name(leader_skin_tone_GDP_growth_lag, replace)
			
twoway ///
		(lpolyci  leader_skin_rel_citizens inflation_GDP_def, fcolor(black*.5%50) lcolor(black) alwidth(none) level(90) n(55) bw(5) gaussian) 	///
		(scatter  leader_skin_rel_citizens inflation_GDP_def, msymbol(circle) mfcolor(black%60)  mlcolor(black))  ///
		,	ylabel(-4 "-4" -3  "{&larr}      "   -2 `""Lighter than" "Mean Citizen""' -1 " " 0 `""Same" "Skin Tone""'   1 " " 2 `""Darker than" "Mean Citizen""' 3  "      {&rarr}"  4 "4", labsize(vsmall)) ///
			xtitle("Inflation (%)", size(small))  ///
			xlabel(-30(10)50, labsize(small))  xscale(range(-31 51)) ///
			xsize(4.25) scheme(s1color) legend(off) ///
			name(leader_skin_tone_inflation, replace)
			
twoway ///
		(lpolyci  leader_skin_rel_citizens inflation_GDP_def_t_1, fcolor(black*.5%50) lcolor(black) alwidth(none) level(90) n(100) bw(5) gaussian) 	///
		(scatter  leader_skin_rel_citizens inflation_GDP_def_t_1, msymbol(circle) mfcolor(black%60)  mlcolor(black))  ///
		,	ylabel(-4 "-4" -3  "{&larr}      "   -2 `""Lighter than" "Mean Citizen""' -1 " " 0 `""Same" "Skin Tone""'   1 " " 2 `""Darker than" "Mean Citizen""' 3  "      {&rarr}"  4 "4", labsize(vsmall)) ///
			xtitle("Inflation (%), Lagged", size(small))  ///
			xlabel(-30(10)50, labsize(small))  xscale(range(-31 51)) ///
			xsize(4.25) scheme(s1color) legend(off) ///
			name(leader_skin_tone_inflation_lag, replace)
			
twoway ///
		(lpolyci  leader_skin_rel_citizens unemployment_ILO, fcolor(black*.5%50) lcolor(black) alwidth(none) level(90) n(100) bw(3) gaussian) 	///
		(scatter  leader_skin_rel_citizens unemployment_ILO, msymbol(circle) mfcolor(black%60)  mlcolor(black))  ///
		,	ylabel(-4 "-4" -3  "{&larr}      "   -2 `""Lighter than" "Mean Citizen""' -1 " " 0 `""Same" "Skin Tone""'   1 " " 2 `""Darker than" "Mean Citizen""' 3  "      {&rarr}"  4 "4", labsize(vsmall)) ///
			xtitle("Unemployment (%)", size(small))  ///
			xlabel(0(5)15, labsize(small))  xscale(range(-1 16)) ///
			xsize(4.25) scheme(s1color) legend(off) ///
			name(leader_skin_tone_unemp, replace)
			
twoway ///
		(lpolyci  leader_skin_rel_citizens unemployment_ILO_t_1, fcolor(black*.5%50) lcolor(black) alwidth(none) level(90) n(100) bw(3) gaussian) 	///
		(scatter  leader_skin_rel_citizens unemployment_ILO_t_1, msymbol(circle) mfcolor(black%60)  mlcolor(black))  ///
		,	ylabel(-4 "-4" -3  "{&larr}      "   -2 `""Lighter than" "Mean Citizen""' -1 " " 0 `""Same" "Skin Tone""'   1 " " 2 `""Darker than" "Mean Citizen""' 3  "      {&rarr}"  4 "4", labsize(vsmall)) ///
			xtitle("Unemployment (%), Lagged", size(small))  ///
						xlabel(0(5)15, labsize(small))  xscale(range(-1 16)) ///
			xsize(4.25) scheme(s1color) legend(off) ///
			name(leader_skin_tone_unemp_lag, replace)
																										
															
graph combine ///
	leader_skin_tone_GDP_growth  ///
	leader_skin_tone_GDP_growth_lag  ///
	leader_skin_tone_inflation  ///
	leader_skin_tone_inflation_lag  ///
	leader_skin_tone_unemp  ///
	leader_skin_tone_unemp_lag  ///
	, 	graphregion(margin(zero)) rows(3) ysize(10) xsize(7) scale(1.05)


restore



			
**************
**************
*Figure A11
**************
**************
gen indig_1 = .
replace indig_1 = 1 if iiet1 == 1
replace indig_1 = 0 if iiet1 == 2

gen indig_2 = .
replace indig_2 = 1 if iiet2 == 1
replace indig_2 = 0 if iiet2 == 2

gen indig_3 = .
replace indig_3 = 1 if iiet3 == 1
replace indig_3 = 0 if iiet3 == 2

sum skin_tone if countryandyear == "Peru_2017" & race~=4
global min = r(min)
global max = r(max)


logit indig_1 skin_tone if race ~=4 
margins, at(skin_tone = ($min(1)$max)) predict(pr) post
est store indig_1

logit indig_2 skin_tone if race ~=4 
margins, at(skin_tone = ($min(1)$max)) predict(pr) post
est store indig_2

logit indig_3 skin_tone if race ~=4 
margins, at(skin_tone = ($min(1)$max)) predict(pr) post
est store indig_3


coefplot ///
	(indig_1, offset(0) recast(line) lcolor(blue%70) lwidth(thick) ciopts(recast(rarea) color(blue%20) lwidth(vvvthin) lcolor(blue*.5%20))) ///
	(indig_2, offset(0) recast(line) lcolor(black%70)  lwidth(thick) ciopts(recast(rarea) color(black%20) lwidth(vvvthin) lcolor(black*.5%20))) ///
	(indig_3, offset(0) recast(line) lcolor(red%70)  lwidth(thick)  ciopts(recast(rarea) color(red%20) lwidth(vvvthin) lcolor(red*.5%20))) ///
	, scheme(s1color) vertical  ///
	xtitle("Skin Tone")  xlabel(1(2)9, labsize(medsmall))	///
	 legend(on order(2 "Control" 4 "Gov. Programs" 6 "Discrim./Low SES") rows(3) size(small))  ///
	ytitle("Pr(Identify as Indigenous)" ) ysize(6)  ylabel(.3(.1).9, labsize(medsmall)) yscale(range(.3 .9)) ///
	graphregion(margin(tiny))




			
**************
**************
*Table A1
**************
**************
xtreg approve_prez c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro, i(cntryyearnum)  fe 
estat ic

xtreg approve_prez c.skin_distance_leader i.ego_retro c.skin_distance_leader#i.darker_than_leader c.skin_distance_leader#i.ego_retro c.skin_distance_leader#i.darker_than_leader#i.ego_retro i.socio_retro ideo_distance_leader i.race education unemployed female, i(cntryyearnum)  fe
estat ic

xtreg approve_prez c.skin_distance_leader i.socio_retro c.skin_distance_leader#i.darker_than_leader c.skin_distance_leader#i.socio_retro c.skin_distance_leader#i.darker_than_leader#i.socio_retro i.ego_retro ideo_distance_leader i.race education unemployed female, i(cntryyearnum)  fe
estat ic




**************
**************
*Evidence for Claim Made in the Text: "In the model that employs linear loss, the AIC is 275013.3. With the quadratic formulation, the AIC is 275023.2... Akaike weights suggest that the probability that the model with the linear loss formulation has a better fit is 0.993."
**************
**************	
xtreg approve_prez c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro, i(cntryyearnum)  fe 
estat ic
matrix FIT=r(S)
scalar aiclinear=FIT[1, 5]

xtreg approve_prez c.skin_distance_leader#c.skin_distance_leader c.skin_distance_leader#c.skin_distance_leader#i.darker_than_leader c.ideo_distance_leader i.race education unemployed female i.ego_retro i.socio_retro, i(cntryyearnum)  fe
estat ic
matrix FIT=r(S)
scalar aicquad=FIT[1, 5]

scalar deltaaic = aiclinear-aicquad
scalar akweight = (exp(-deltaaic/2))/((exp(-deltaaic/2)) + 1)
di akweight



**************
**************
*Evidence for Claim Made in the Text: "We exclude anyone who claimed Afro-Latin heritage from the analysis, but substantive results are not sensitive to this exclusion."
**************
**************	
sum skin_tone if countryandyear == "Peru_2017" 
global min = r(min)
global max = r(max)


logit indig_1 skin_tone
margins, at(skin_tone = ($min(1)$max)) predict(pr) post
est store indig_1

logit indig_2 skin_tone 
margins, at(skin_tone = ($min(1)$max)) predict(pr) post
est store indig_2

logit indig_3 skin_tone 
margins, at(skin_tone = ($min(1)$max)) predict(pr) post
est store indig_3


coefplot ///
	(indig_1, offset(0) recast(line) lcolor(blue%70) lwidth(thick) ciopts(recast(rarea) color(blue%20) lwidth(vvvthin) lcolor(blue*.5%20))) ///
	(indig_2, offset(0) recast(line) lcolor(black%70)  lwidth(thick) ciopts(recast(rarea) color(black%20) lwidth(vvvthin) lcolor(black*.5%20))) ///
	(indig_3, offset(0) recast(line) lcolor(red%70)  lwidth(thick)  ciopts(recast(rarea) color(red%20) lwidth(vvvthin) lcolor(red*.5%20))) ///
	, scheme(s1color) vertical  ///
	xtitle("Skin Tone")  xlabel(1(2)9, labsize(medsmall))	///
	 legend(on order(2 "Control" 4 "Gov. Programs" 6 "Discrim./Low SES") rows(3) size(small))  ///
	ytitle("Pr(Identify as Indigenous)" ) ysize(6)  ylabel(.3(.1).9, labsize(medsmall)) yscale(range(.3 .9)) ///
	graphregion(margin(tiny))



**************
**************
*Evidence for Claim Made in the Text: "In each case, the average marginal effect of skin tone on the probability of Indigenous self-identification is statistically significant (the two-sided p-value is .003 in the control condition, .011 in the Government Programs condition, and .054 in the Discrimination/Low Socioeconomic Status condition)."
**************
**************	
logit indig_1 skin_tone if race ~=4 
margins, dydx(skin_tone) predict(pr)

logit indig_2 skin_tone if race ~=4 
margins, dydx(skin_tone) predict(pr)

logit indig_3 skin_tone if race ~=4 
margins, dydx(skin_tone) predict(pr)





**************
**************
*Open the ANES Dataset
**************
**************
use "ANES_Singh_and_Carlin_CPS.dta", clear




**************
**************
*Figure A13
**************
**************
sum skin_distance_leader 
global mean_skin = r(mean)

histogram skin_distance_leader,   ///
	fcolor(gs5) fintensity(100) lcolor(white) lwidth(vthick)  lalign(center) bin(10)  ///
				xlabel(	-9 "-9"  ///
						-6 `""-6" "{&larr}  Lighter" "   than Obama""'  ///
						-3 	"-3"  ///
						0 `""0" "Same Skin Tone"   "as Obama""' ///
						3 	"3"   ///
						6 `""6" "Darker  {&rarr}" "than Obama     ""' ///
						9 "9" ///
					, labsize(small)) ylabel(, labsize(small)) ///
					xtitle("") ///
	addplot(pci 0.003 $mean_skin  .3 $mean_skin, lcolor(black*1.25) lpattern(dash)) legend(off) /// 
	xsize(4.25) scheme(s1color) title("") note("") 
	
gr_edit .plotregion1.style.editstyle margin(small) editcopy



**************
**************
*Figure A14
**************
**************
reg approve_obama c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader education unemployed female i.race i.ego_retro i.socio_retro, cl(state) 

sum skin_distance_leader 
global min = r(min)
global max = r(max)
global increment_light = abs(($min-0)/20)
global increment_dark = abs(($max-0)/20)
margins, at(skin_distance_leader = ($min($increment_light)0) darker_than_leader=0) at(skin_distance_leader = (0($increment_dark)$max) darker_than_leader=1) predict(xb) atmeans level(90) post

marginsplot, level(90)  ///
     recast(line) recastci(rarea) scheme(s1color) ///
     ci1opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot1opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 ci2opts(color(black*.5%50) lwidth(vthin) lcolor(black*.2%50))  /// 
     plot2opts(lcolor(black*1.25%50) lwidth(medium))  /// 
	 title("")  ///
	 xsize(4.25)	 ///
	 addplot(histogram skin_distance_leader    ///  
		, 	yaxis(2) xaxis(2) lcolor(black) lpattern(solid) ///
			xlabel(	-9 "-9"  ///
						-6 `""-6" "{&larr}  Lighter" "   than Obama""'  ///
						-3 	"-3"  ///
						0 `""0" "Same Skin Tone"   "as Obama""' ///
						3 	"3"   ///
						6 `""6" "Darker  {&rarr}" "than Obama     ""' ///
						9 "9" ///
					, labsize(small)) ylabel(, labsize(small)) ///
					xscale(range(-9 9) lwidth(none)  axis(2)) xlabel(none, axis(2)) ///
			xtitle("") ///
			xtitle("", axis(2)) ///
			ylabel(2.5(.25)3.5, labsize(small))  yscale(range(2.35 3.55)) ///
			ylabel(0 45, axis(2)) fcolor(gs2) lcolor(gs2) lwidth(vthin) lalign(center) gap(0) width(.15)  ///  
			yscale(off   axis(2)) ///
			ytitle("Predicted Approval of Obama", size(medsmall)) ///
			ytitle("", axis(2)) ///
			legend(off))




			
**************
**************
*Table A2
**************
**************
reg approve_obama c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader education unemployed female i.race i.ego_retro i.socio_retro, cl(state) 
estat ic




**************
**************
*Evidence for Claim Made in the Text: "Sample mean [of Obama approval] is 2.93."
**************
**************	
sum approve_obama	
			

			

**************
**************
*Evidence for Claim Made in the Text: "The median Rater took 2 minutes and 7 seconds to complete the task."
**************
**************	
preserve 

***
*Open the required data set.
***
use "Complexion_Ratings_with_Obama.dta", clear

***
*Do the analysis
***
sum durationinseconds, detail
global p50 = r(p50)
di r(p50)/60 //*in minutes
		
restore		
		
		
		
**************
**************
*Evidence for Claim Made in the Text: "The distribution of this variable in our sample, the mean of which is −1.24...  
*About 30 percent of respondents were assessed to have a darker skin tone than Obama."
**************
**************	
sum skin_distance_leader
sum skin_distance_leader if skin_distance_leader<0
global number_lighter = r(N)
sum skin_distance_leader if skin_distance_leader>0
global number_darker = r(N)
sum skin_distance_leader
global number_total = r(N)

di $number_lighter/$number_total //*percent lighter than Obama
di $number_darker/$number_total //*percent darker than Obama



		
**************
**************
*Evidence for Claim Made in the Text: "The difference in the two slope estimates is statistically significant at p < .010, two sided."
**************
**************
reg approve_obama c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader education unemployed female i.race i.ego_retro i.socio_retro, cl(state) 
margins, dydx(skin_distance_leader) at(darker_than_leader = (0 1)) predict(xb) atmeans level(90) post coeflegend
lincom _b[skin_distance_leader:1bn._at] -  _b[skin_distance_leader:2._at]




**************
**************
*Evidence for Claim Made in the Text: "going from an exact skin tone match to three shades lighter on the palette shown in Figure A14 corresponds 
*with a decline in predicted approval of 0.173 units (p = .041, two-sided)... going from an exact skin tone match to being three shades darker corresponds 
*with a trivial and insignificant change in predicted approval of −0.012 units (p = .841, two-sided)."
**************
**************
reg approve_obama c.skin_distance_leader c.skin_distance_leader#i.darker_than_leader ideo_distance_leader education unemployed female i.race i.ego_retro i.socio_retro, cl(state)
margins, dydx(skin_distance_leader) at(darker_than_leader = (0 1)) predict(xb) atmeans level(90) post coeflegend
lincom 3 *  _b[skin_distance_leader:1bn._at]  //*impact of a three unit shift for lighter side
lincom 3 *   _b[skin_distance_leader:2._at] //*impact of a three unit shift for darker side














